function e(e) {
    e || (e = {}), e.accessToken || (e.accessToken = getApp().globalData.accessToken), 
    e.accessToken || (e.accessToken = ""), void 0 == e.accessToken && (e.accessToken = "");
    for (var t in e) void 0 == (p = e[t]) ? e[t] = "" : "[object Object]" === Object.prototype.toString.call(p) && (e[t] = JSON.stringify(p));
    e.version = 6666, e.deviceType = "weixin", e.timestrap = new Date().getTime(), getApp().globalData.authToken && (e.authToken = getApp().globalData.authToken);
    var a = [];
    for (var r in e) a.push(r);
    a.sort();
    for (var c = "", i = {}, l = 0; l < a.length; l++) {
        var t = a[l], p = e[a[l]];
        c += t + "=" + p, i[t] = p, l != a.length - 1 && (c += "&");
    }
    c += "&signStr=co.uynuh.www", getApp().log(c), n = c;
    var u = getApp().md5.md5(c);
    s = u, e.sign = u, i.sign = u;
    var f = JSON.stringify(i);
    o = f;
    var g = getApp().AES.Encrypt(f);
    o = g;
    var d = {};
    return d.paramData = g, d.version = e.version, d;
}

function t(t, r) {
    getApp().log(r);
    var c = e(r.params);
    r.before && r.before(), wx.request({
        url: a + r.url,
        data: c,
        method: t,
        header: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        success: function(e) {
            getApp().log(e.data), -1 == e.data.result ? (wx.showToast({
                title: e.data.message,
                icon: "none",
                duration: 2e3
            }), wx.request({
                url: "https://www.hunyu.co/appweb/weixinProgramSignError.do",
                data: {
                    paramData: o,
                    signStr: n,
                    sign: s,
                    met: r.url
                },
                method: "GET",
                success: function(t) {
                    getApp().log("签名错误上传:", e.data);
                }
            })) : r.success && r.success(e);
        },
        fail: function() {
            r.fail && r.fail();
        },
        complete: function() {
            r.complete && r.complete();
        }
    });
}

var a = "https://www.ihunyu.com/app/", o = "", n = "", s = "";

module.exports = {
    get: function(e) {
        t("GET", e);
    },
    post: function(e) {
        t("POST", e);
    },
    uploadFile: function(t) {
        getApp().log(t);
        var o = e(t.formData);
        return t.before && t.before(), wx.uploadFile({
            url: a + t.url,
            filePath: t.filePath,
            name: t.name,
            formData: o,
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function(e) {
                if (200 == e.statusCode) {
                    var a = JSON.parse(e.data);
                    -1 == a.result ? wx.showToast({
                        title: a.message,
                        icon: "none",
                        duration: 2e3
                    }) : t.success && t.success(a);
                } else t.fail && t.fail();
            },
            fail: function() {
                t.fail && t.fail();
            },
            complete: function() {
                t.complete && t.complete();
            }
        });
    },
    url: a
};